import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/** note: sub-menu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']    will control the page roles (you can set multiple roles)
    title: 'title'               the name show in sub-menu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if true, the page will no be cached(default is false)
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
    affix: true                  if true, the tag will affix in the tags-view
  }
**/
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  }, {
    path: '/',
    redirect: '/index',
    component: Layout,
    hidden: false,
    meta: { title: '首页', icon: 'index' },
    children: [
      {
        path: '/index',
        name: 'index',
        meta: { title: '首页', icon: '' },
        // children: [],
        component: () => import('@/views/index')
      }
    ]
  }, {
    path: '/recommend',
    redirect: '/recommend/ad',
    component: Layout,
    hidden: false,
    meta: { title: '广告&首页推荐', icon: 'index' },
    children: [
      {
        path: 'ad',
        name: 'ad',
        meta: { title: '广告位管理', icon: '' },
        component: () => import('@/views/recommend/ad')
      },
      {
        path: 'setindex',
        name: 'setindex',
        meta: { title: '首页配置', icon: '' },
        component: () => import('@/views/recommend/setindex')
      },
      {
        path: 'item',
        name: 'courseEdit',
        hidden: true,
        meta: { title: '编辑详情', icon: '' },
        component: () => import('@/views/recommend/item')
      }
    ]
  }, {
    path: '/lecturers',
    redirect: '/lecturersList',
    component: Layout,
    hidden: false,
    name: 'lecturers',
    meta: { title: '讲师管理', icon: 'index' },
    children: [
      {
        path: '/lecturersList',
        meta: { title: '讲师总览', icon: '' },
        name: 'lecturersList',
        hidden: false,
        children: [],
        component: () => import('@/views/lecturers/lecturersList')
      },
      {
        path: '/enitTeacher',
        meta: { title: '讲师详情', icon: '' },
        name: 'enitTeacher',
        hidden: true,
        children: [],
        component: () => import('@/views/lecturers/enitTeacher')
      }]
  }, {
    path: '/mine',
    redirect: '/mine/index',
    component: Layout,
    hidden: true,
    meta: { title: '个人中心', icon: 'index' },
    children: [
      {
        path: '/mine/index',
        name: 'mine',
        meta: { title: '个人中心', icon: '' },
        component: () => import('@/views/mine/index')
      }
    ]
  }, {
    path: '/PMP',
    redirect: '/pmpList',
    component: Layout,
    hidden: false,
    name: 'PMP',
    meta: { title: '项目管理', icon: 'index' },
    children: [
      {
        path: '/pmpList',
        meta: { title: '项目总览', icon: '' },
        name: 'pmpList',
        hidden: false,
        children: [],
        component: () => import('@/views/PMP/pmpList')
      }
    ]
  }, {
    path: '/package',
    redirect: '/packageList',
    component: Layout,
    hidden: true,
    name: 'package',
    meta: { title: '产品包管理', icon: 'index' },
    children: [
      {
        path: '/packageList',
        meta: { title: '产品包总览', icon: '' },
        name: 'packageList',
        hidden: false,
        children: [],
        component: () => import('@/views/packages/packageList')
      },
      {
        path: '/packageDetail',
        meta: { title: '产品包信息', icon: '' },
        name: 'packageDetail',
        hidden: true,
        children: [],
        component: () => import('@/views/packages/packageDetail')
      },
      {
        path: '/proDaily',
        meta: { title: '修改日志', icon: '' },
        name: 'proDaily',
        hidden: false,
        children: [],
        component: () => import('@/views/packages/proDaily')
      },
      {
        path: '/subjectModul',
        meta: { title: '课程模块', icon: '' },
        name: 'subjectModul',
        hidden: true,
        children: [],
        component: () => import('@/views/packages/subjectModul')
      },
      {
        path: '/subjectMent',
        meta: { title: '课程安排', icon: '' },
        name: 'subjectMent',
        hidden: true,
        children: [],
        component: () => import('@/views/packages/subjectMent')
      }]
  }, {
    path: '/Statelesspublic',
    redirect: '/Statelesspublic/index',
    component: Layout,
    hidden: false,
    name: 'Statelesspublic',
    meta: { title: '公开课管理', icon: 'index' },
    children: [
      {
        path: '/Statelesspublic/index',
        name: 'StatelesspublicIndex',
        meta: { title: '公开课总览', icon: '' },
        component: () => import('@/views/Statelesspublic/index'),
        children: []
      },
      {
        path: '/Statelesspublic/edit',
        name: 'StatelesspublicEdit',
        meta: { title: '详情', icon: '' },
        children: [],
        hidden: true,
        component: () => import('@/views/Statelesspublic/editState')
      }
    ]
  }, {
    path: '/User',
    redirect: '/userList',
    component: Layout,
    hidden: false,
    name: 'User',
    meta: { title: '用户管理', icon: 'index' },
    children: [
      {
        path: '/userList',
        meta: { title: '用户总览', icon: '' },
        name: 'userList',
        hidden: false,
        children: [],
        component: () => import('@/views/mangement/userList')
      },
      {
        path: '/qulicationList',
        meta: { title: '证书总览', icon: '' },
        name: 'qulicationList',
        hidden: false,
        children: [],
        component: () => import('@/views/mangement/qulicationList')
      },
      {
        path: '/sendCation',
        meta: { title: '发放证书', icon: '' },
        name: 'sendCation',
        hidden: true,
        children: [],
        component: () => import('@/views/mangement/sendCation')
      },
      {
        path: '/preview',
        meta: { title: '预览', icon: '' },
        name: 'preview',
        hidden: true,
        children: [],
        component: () => import('@/views/mangement/preview')
      }]
  }, {
    path: '/CourseGroup',
    redirect: '/CourseGroup/index',
    component: Layout,
    hidden: false,
    name: 'CourseGroup',
    meta: { title: '科目管理', icon: 'index' },
    children: [
      {
        path: '/CourseGroup/index',
        name: 'CourseIndex',
        meta: { title: '科目总览', icon: '' },
        children: [],
        component: () => import('@/views/CourseGroup/index')
      },
      {
        path: '/CourseGroup/module',
        name: 'CourseModule',
        meta: { title: '科目模块（课型）总览', icon: '' },
        children: [],
        component: () => import('@/views/CourseGroup/module')
      },
      {
        path: '/CourseGroup/class',
        name: 'CourseClass',
        meta: { title: '课总览', icon: '' },
        children: [],
        component: () => import('@/views/CourseGroup/class')
      }
    ]
  }, {
    path: '/Admin',
    redirect: '/adminList',
    component: Layout,
    hidden: false,
    name: 'Admin',
    meta: { title: '系统管理', icon: 'index' },
    children: [
      {
        path: '/adminList',
        meta: { title: '系统用户总览', icon: '' },
        name: 'adminList',
        hidden: false,
        children: [],
        component: () => import('@/views/adminIsration/adminList')
      },
      {
        path: '/editAccount',
        meta: { title: '创建账户', icon: '' },
        name: 'editAccount',
        hidden: true,
        children: [],
        component: () => import('@/views/adminIsration/editAccount')
      }
    ]
  }, {
    path: '/material',
    redirect: '/material/index',
    component: Layout,
    hidden: false,
    name: 'material',
    meta: { title: '内容管理', icon: 'index' },
    children: [
      {
        path: '/material/index',
        name: 'materialIndex',
        meta: { title: '视频资源总览', icon: '' },
        children: [],
        component: () => import('@/views/Material/index')
      }]
  },
  {
    path: '/material/video',
    name: 'materialVideoIndex',
    meta: { title: '视频资源总览', icon: '' },
    children: [],
    hidden: true,
    component: () => import('@/views/Material/video')
  }, {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  }, {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  }, {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = []
